<template>
    <div>
        <h1>Checkbox 复选框</h1>
        <p>简单常用的复选框</p>
        <div>
            <h2>基础用法</h2>
            <p>单独使用可以表示两种状态之间的切换，通过v-model绑定状态值。</p>
            <div class="preview-box">
                <div style="padding:20px">
                    <div class="flex-start">
                        <mo-checkbox v-model="flag" name="0">测试</mo-checkbox>
                    </div>
                </div>
                <div class="code-box" v-show="button1">
                    <pre v-highlight><code class="html">{{ code1 }}</code></pre>  
                </div>
                <div class="preview-code flex-center">
                    <el-link :underline="false" @click="button1=!button1">
                        {{button1?'隐藏源代码':'查看源代码'}}
                    </el-link>
                </div>
            </div>
        </div>

        <div>
            <h2>禁用状态</h2>
            <p>使用 disabled 属性来控制是否为禁用状态。 该属性接受一个 Boolean 类型的值。</p>
            <div class="preview-box">
                <div style="padding:20px">
                    <div class="flex-start">
                        <mo-checkbox v-model="flag1" disabled name="1">测试</mo-checkbox>
                        <mo-checkbox v-model="flag2" disabled name="2" style="margin-left: 10px;">测试</mo-checkbox>
                    </div>
                </div>
                <div class="code-box" v-show="button2">
                    <pre v-highlight><code class="html">{{ code2 }}</code></pre>  
                </div>
                <div class="preview-code flex-center">
                    <el-link :underline="false" @click="button2=!button2">
                        {{button2?'隐藏源代码':'查看源代码'}}
                    </el-link>
                </div>
            </div>
        </div>

        <div>
            <h2>圆角样式</h2>
            <p>使用 round 属性来定义复选框的圆角状态。 该属性接受一个 Boolean 类型的值。</p>
            <div class="preview-box">
                <div style="padding:20px">
                    <div class="flex-start">
                        <mo-checkbox v-model="flag3" round name="3">测试</mo-checkbox>
                    </div>
                </div>
                <div class="code-box" v-show="button3">
                    <pre v-highlight><code class="html">{{ code3 }}</code></pre>  
                </div>
                <div class="preview-code flex-center">
                    <el-link :underline="false" @click="button3=!button3">
                        {{button3?'隐藏源代码':'查看源代码'}}
                    </el-link>
                </div>
            </div>
        </div>

         <div>
            <h2>自定义大小</h2>
            <p>使用 size 属性来自定义按钮的大小。 该属性接受一个 String 类型的 large,medium,small 三种值。</p>
            <div class="preview-box">
                <div style="padding:20px">
                    <div class="flex-start">
                        <mo-checkbox v-model="flag3" name="4" size="small">测试</mo-checkbox>
                        <mo-checkbox style="margin-left:10px" v-model="flag3" name="5" size="medium">测试</mo-checkbox>
                        <mo-checkbox style="margin-left:10px" v-model="flag3" name="6" size="large">测试</mo-checkbox>
                    </div>
                </div>
                <div class="code-box" v-show="button4">
                    <pre v-highlight><code class="html">{{ code4 }}</code></pre>  
                </div>
                <div class="preview-code flex-center">
                    <el-link :underline="false" @click="button4=!button4">
                        {{button4?'隐藏源代码':'查看源代码'}}
                    </el-link>
                </div>
            </div>
        </div>

        <div>
            <h2>属性</h2>
             <el-table 
                :data="attrList" 
                style="width: 800px"
                :header-cell-style="{background:'#f5f7fa',color:'#606266'}">
                    <el-table-column property="attr" label="属性"/>
                    <el-table-column property="desc" label="描述" />
                    <el-table-column property="type" label="类型"/>
                    <el-table-column property="opt" label="可选值" />
                    <el-table-column property="default" label="默认值"/>
             </el-table>
        </div>

        <div>
            <h2>事件</h2>
             <el-table 
                :data="eventList" 
                style="width: 800px"
                :header-cell-style="{background:'#f5f7fa',color:'#606266'}">
                    <el-table-column property="event" label="事件名"/>
                    <el-table-column property="desc" label="描述" />
                    <el-table-column property="temp" label="参数"/>
             </el-table>
        </div>
    </div>
</template>

<script>
import { computed, reactive, ref, toRefs } from 'vue';
import code from '@/views/component/checkbox/code';
import attrs from '@/views/component/checkbox/attrs';
export default {
    name: 'checkbox',
    components: {},
    props: {},
    emits: [],
    setup () 
    {
        let data = reactive({
            button1:false,
            button2:false,
            button3:false,
            button4:false,
            flag:true,
            flag1:false,
            flag2:true,
            flag3:true
        });
        function test (value)
        {
            console.log(value);
        }
        
        return {
            ...code,
            ...toRefs(data),
            ...attrs,
            test
        };
    }
};

</script>
<style lang='scss' scoped>

</style>
